import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import { ENV, DEV_DOMAIN, PRO_DOMAIN } from "./src/config";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [uni()],
  base: "./",

  server: {
    port: 5173,
    proxy: {
      "/api": {
        target: ENV === "dev" ? DEV_DOMAIN : PRO_DOMAIN,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, "/"),
      },
    },
  },
});
